<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>

        /**
         * 数据类型转换通常指将其他数据类型转成 字符串 数字 布尔值
         * 数据类型转换有两种: 强制转换(显式转换) 和 自动转换(隐式转换)
         * 
         * 强制转换(显式转换): 其他类型 转成 布尔值
         * 除了 ''空串 、0、NaN 、false、null、undefined转换成布尔值为false，其余都为true
        */
           var str1 = '';// 空串
        var str2 = 'hello';// 非空串
        var num1 = 0;// 0
        var num2 = 123;// 非0
        var num3 = NaN;
        var boo1 = true;
        var boo2 = false;
        var nul = null;
        var und = undefined;
        var obj = { a: 1, b: 2 };
        var fun = function () { };
        var arr1 = [];
        var arr2 = [6];
        var arr3 = [7, 8, 9];

        console.log(Boolean(str1));//false
        console.log(Boolean(str2));
        console.log(Boolean(num1));//false
        console.log(Boolean(num2));
        console.log(Boolean(num3));//false
        console.log(Boolean(boo1));
        console.log(Boolean(boo2));//false
        console.log(Boolean(nul));//false
        console.log(Boolean(und));//false
        console.log(Boolean(obj));
        console.log(Boolean(fun));
        console.log(Boolean(arr1));
        console.log(Boolean(arr2));
        console.log(Boolean(arr3));
    </script>
</body>
</html>